Prima cesta na desktop

Otázka od: Milos J. Hrach

10. 12. 2003 12:36

Mam nasledujici problem.Potrebuji pri behu programu ukladat nejake
informace na plochu(desktop). Kazda wokna maji ovsem jinou cestu.
Existuje nejaky zastupce, ktery identifikuje plochu v kazde versi
woken (jako napr. %systemroot% nahrazuje cestu c:\windows)?

--
VOLNY Bingo - vyzvednete si svou hraci kartu
a vyhrajte nekterou z 38 cen!
http://soutez.volny.cz/slepa.php


Odpovedá: Ludek ZITA

10. 12. 2003 12:53

This is a multi-part message in MIME format.



Odpovedá: Petr Vones

10. 12. 2003 12:57

From: "Milos J. Hrach" <jhrach@post.cz>
> Existuje nejaky zastupce, ktery identifikuje plochu v kazde versi
> woken (jako napr. %systemroot% nahrazuje cestu c:\windows)?

Pouzij funkci GetDesktopFolder z JclSysInfo:
http://sourceforge.net/project/showfiles.php?group_id=47514&release_id=118195

Petr Vones

Odpovedá: Ludek ZITA

10. 12. 2003 13:45

----- Original Message -----
From: "Milos J. Hrach" <jhrach@post.cz>
To: <delphi-l@clexpert.cz>
Sent: Wednesday, December 10, 2003 12:19 PM
Subject: Prima cesta na desktop


> Mam nasledujici problem.Potrebuji pri behu programu ukladat nejake
> informace na plochu(desktop). Kazda wokna maji ovsem jinou cestu.
> Existuje nejaky zastupce, ktery identifikuje plochu v kazde versi
> woken (jako napr. %systemroot% nahrazuje cestu c:\windows)?

Ahoj.
%USERPROFILE%\Plocha ?
Nebo si smust cmd a mrkni na vypis prikazu "set"

Ludek



Odpovedá: Petr Vones

10. 12. 2003 16:05

From: "Ludek ZITA" <konference@sales.cz>
> %USERPROFILE%\Plocha ?

Tohle je ovsem zavisle na lokalizaci Windows.

Petr Vones

Odpovedá: Jiri Virt

11. 12. 2003 7:47

unit adresare;
interface

uses shlobj,sysutils,ShellAPI,windows;

function GetFolder(folder:string):string;
procedure SendToRecycleBin(ApplicationHandle:THandle;FileName: string);

implementation

function GetFolder(folder:string):string;
var
Retezec:PChar;
pid:PItemIDList;
FolderType:integer;
begin
FolderType := 0;
if UpperCase(folder)= 'KOS'then FolderType := CSIDL_BITBUCKET;
if UpperCase(folder)= 'OVL_PANEL'then FolderType := CSIDL_CONTROLS;
if UpperCase(folder)= 'DESKTOP'then FolderType := CSIDL_DESKTOP;
if UpperCase(folder)= 'DESKTOP_DIR'then FolderType :=
CSIDL_DESKTOPDIRECTORY;
if UpperCase(folder)= 'TENTO_POC'then FolderType := CSIDL_DRIVES;
if UpperCase(folder)= 'FONTY'then FolderType :=CSIDL_FONTS;
if UpperCase(folder)= 'NETHOOD'then FolderType :=CSIDL_NETHOOD;
if UpperCase(folder)= 'NETWORK'then FolderType :=CSIDL_NETWORK;
if UpperCase(folder)= 'PRINTERS'then FolderType :=CSIDL_PRINTERS;
if UpperCase(folder)= 'PROGRAMY'then FolderType := CSIDL_PROGRAMS;
if UpperCase(folder)= 'POSL_DOK'then FolderType := CSIDL_RECENT;
if UpperCase(folder)= 'ODESLAT'then FolderType := CSIDL_SENDTO;
if UpperCase(folder)= 'START_MENU'then FolderType := CSIDL_STARTMENU;
if UpperCase(folder)= 'START_UP'then FolderType := CSIDL_STARTUP;
if UpperCase(folder)= 'TEMPS'then FolderType := CSIDL_TEMPLATES;
if UpperCase(folder)= 'DOKUMENTY' then FolderType := CSIDL_PERSONAL;
GetMem(Retezec,255);
SHGetSpecialFolderLocation(0,FolderType,pID);
SHGetPathFromIDList(PID,Retezec);
result:=Retezec;
FreeMem(Retezec,255);
end;

procedure SendToRecycleBin(ApplicationHandle:THandle;FileName: string);
var
  SHF: TSHFileOpStruct;
begin
  with SHF do begin
    Wnd := ApplicationHandle;
    wFunc := FO_DELETE;
    pFrom := PChar(FileName);
    fFlags := FOF_SILENT or FOF_ALLOWUNDO;
  end;
  SHFileOperation(SHF);
end;
end.


Jirka Virt